from collections import deque

#广度优先搜索算法



# 定义一个字典
graph = {}
graph["you"] = ["alice", "bob", "claire"]
graph["bob"] = ["anuj", "peggy"]
graph["alice"] = ["peggy"]
graph["claire"] = ["thom", "jonny"]
graph["anuj"] = []
graph["peggy"] = []
graph["thom"] = []
graph["jonny"] = []


def persion_is_seller(name):
    return name[-1] == "m"


serach_queue = deque()
serach_queue += graph["you"]

while serach_queue:
    persion = serach_queue.popleft()
    if persion_is_seller(persion):
        print(persion + " is seller")
        break
    else:
        serach_queue += graph[persion]

